package com.qinggeng.project.system.service.impl;

import com.qinggeng.project.api.dto.ActivityGoodsDto;
import com.qinggeng.project.api.dto.GoodsActivityDto;
import com.qinggeng.project.system.domain.GoodsActivity;
import com.qinggeng.project.system.mapper.GoodsActivityMapper;
import com.qinggeng.project.system.service.IGoodsActiviyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 商品活动业务层处理
 *
 * @author 吴鹏飞
 * @date 2020/9/3
 */
@Service
public class GoodsActivityServiceImpl implements IGoodsActiviyService {
    @Autowired
    private GoodsActivityMapper goodsActivityMapper;

    @Override
    public GoodsActivity selectFirstGoodsActivity() {
        return goodsActivityMapper.selectFirstGoodsActivity();
    }

    @Override
    public List<GoodsActivity> selectGoodsActivity(GoodsActivity goodsActivity) {
        return goodsActivityMapper.selectGoodsActivitys(goodsActivity);
    }

    @Override
    public int insertGoodsActivity(GoodsActivity goodsActivity) {
        return goodsActivityMapper.insertGoodsActivity(goodsActivity);
    }
    /**
     * 通过goodsId修改beatNum
     * @param goodsId
     * @param groupNum
     */
    @Override
    public void updateGoodsActivityOnGroupNumByGoodsId(Long goodsId, Integer groupNum) {
        goodsActivityMapper.updateGoodsActivityOnGroupNumByGoodsId(goodsId,groupNum);
    }

    /**
     * 根据商品id查出捶一捶商品关联信息
     * @param goodsId
     */
    @Override
    public ActivityGoodsDto selectGooodsActivityDtoBy(Long goodsId) {
       return goodsActivityMapper.selectGooodsActivityDtoBy(goodsId);
    }
}
